<!DOCTYPE html>
<html lang="zh-Hans">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>精美原生JS响应式计算器</title>
  <link rel="stylesheet" type="text/css" href="./css/style.css">
  <script>
    (function (selector) {
      var resizeEvt = 'onorientationchange' in window ? 'orientationchange' : 'resize';
      var calcREM = function(base, min, max, scaling) {
        var docEl = document.documentElement;
        var clientWidth = docEl.clientWidth;
        if (!clientWidth) return;
        clientWidth = Math.max(min, Math.min(clientWidth, max));
        docEl.style.fontSize = scaling * (clientWidth / base) + 'px';
      }
      var resize = function () {
        calcREM(375, 300, document.querySelector(selector).clientWidth, 100);
      };
      if (!document.addEventListener) return;
      window.addEventListener(resizeEvt, resize);
      document.addEventListener('DOMContentLoaded', resize);
    })('.calculator');
  </script>
</head>
<body>
  <div class="calculator">
    <div class="calc-screen">
      <div class="calc-result"><span class="data">0</span></div>
    </div>
    <div class="calc-buttons">
      <input type="button" class="buttons" value="AC">
      <input type="button" class="buttons" value="←">
      <input type="button" class="buttons" value="%">
      <input type="button" class="buttons" value="÷">
      <input type="button" class="buttons" value="7">
      <input type="button" class="buttons" value="8">
      <input type="button" class="buttons" value="9">
      <input type="button" class="buttons" value="×">
      <input type="button" class="buttons" value="4">
      <input type="button" class="buttons" value="5">
      <input type="button" class="buttons" value="6">
      <input type="button" class="buttons" value="-">
      <input type="button" class="buttons" value="1">
      <input type="button" class="buttons" value="2">
      <input type="button" class="buttons" value="3">
      <input type="button" class="buttons" value="+">
      <input type="button" class="buttons" value="±">
      <input type="button" class="buttons" value="0">
      <input type="button" class="buttons" value=".">
      <input type="button" class="buttons equals" value="=">
    </div>
  </div>
  <script type="text/javascript" src="./js/app.js"></script>
  <script>
    Calculator({
      el:       '.calculator',
      buttons:  '.calc-buttons',
      output:   '.calc-result>.data'
    });
  </script>
</body>
</html>